<style type="text/css">
<!--

.boxy-wrapper .answers {width:80px;}

-->
</style>



<form action="{:U('weibo/Operate/myedit')}" method="post" id="transpondForm">
	<input type="hidden" name="weibo_id" value="{$data.weibo_id}" />





<div style="width:370px; text-align:left">

	<div style="padding:20px 10px 0 10px;">{$data.content|keyWordFilter|format}</div>



<div style="padding:5px 10px 0 10px;">

          <select name="bc_id" id="bc_id" style="width:122px;">
              
              
              <volist name="bcdisplay"  id="bcd">
                 
                  <option value="{$bcd.bc_id}"  <if condition="$bcd.bc_id eq $data['bc_id']">selected="selected"</if>>{$bcd.title}</option>
                      
                      
              </volist> 
              
               
		</select> <input type="text" name="bcTitle"  value="添加新图格" class="text" style="width:120px; color:#888;" onfocus="if(value=='添加新图格') {value=''}" onblur="if (value=='') {value='添加新图格'}"/>

        <input type="button" onclick="createBc()"  class="btn_b" value="创建"/></h2>

</div>


<div  style="padding:10px">
<span class="right" id="transpond_count" style="color:#008800">还可以输入131个汉字</span>
</div>

<div style="padding:0 10px">
<textarea id="transpond_content_{$data.weibo_id}" name="content" style="font-family: Tahoma,宋体; overflow: hidden; border: 1px solid #ccc; background-color:#F8F8F8; word-wrap: break-word; font-size: 12px; line-height: 18px; height: 65px; width:328px;">
<php>if($data['transponInfo']){</php>
{$data.content}
<php>}</php>
</textarea>
 
</div>



<div style="margin:0 0 0 12px;"> <span>添加：</span>
    <a href="javascript:void(0)" target_set="transpond_content_{$data.weibo_id}" onclick="ui.emotions(this);" class="a52"><img class="icon_add_face_d" src="__THEME__/images/zw_img.gif" />表情</a>
</div>
<div class="c"></div>

<div><if condition="$data.weibo_id">
<php>if( $data['uid'] == $mid ){</php><div style="width:200px;padding:15px;"><a href="javascript:void(0)" onclick="ui.confirm(this,'确认要删除此分享?')" callback="weibo.deleted({$data.weibo_id})" title="删除?"><span style="color:red;">x 删除</span></a></div><php>}</php>

</if>
<div class="answers right"><input type="button" onclick="dotranspond()" id="transpond_button" class="btn_b right" value="确定"></div>
</div>
</form>

<script>
$(document).ready(function(){
	var content_handle = "transpond_content_{$data.weibo_id}";
	var content_jquery_handle = $('#'+content_handle);
	var Interval;

	var default_transpond_string = "{$data.content}";

	content_jquery_handle.keypress(function(event){
		var key = event.keyCode?event.keyCode:event.which?event.which:event.charCode;
        if (key == 27) {
        	clearInterval(Interval);
        }
		checkTranspondLength(content_jquery_handle,140);
	}).blur(function(){
		clearInterval(Interval);
	    if(content_jquery_handle.val() == '') {
	        content_jquery_handle.val(default_transpond_string);
	    }
        checkTranspondLength(content_jquery_handle,140);
	}).focus(function(){
	    if(content_jquery_handle.val() == default_transpond_string) {
	        content_jquery_handle.val('');
	        checkTranspondLength(content_jquery_handle,140);
	    }
	    //微博字数监控
		clearInterval(Interval);
	    Interval = setInterval(function(){
	    	checkTranspondLength(content_jquery_handle,140);
		},300);
	});

	if (content_jquery_handle.val() == '') {
		content_jquery_handle.val(default_transpond_string);
        checkTranspondLength(content_jquery_handle,140);
	}else {
		var textArea = document.getElementById('transpond_content_{$data.weibo_id}');
	    if (document.selection) { //IE
	         var rng = textArea.createTextRange();
	         rng.collapse(true);
	         rng.moveStart("character",0)
	    }else if (textArea.selectionStart || (textArea.selectionStart == '0')) { // Mozilla/Netscape…
	        textArea.selectionStart = 0;
	        textArea.selectionEnd = 0;
	    }
		checkTranspondLength(content_jquery_handle,140);
		textArea.focus();
	}

	shortcut('ctrl+return',	function(){dotranspond();clearInterval(Interval);},{'target':content_handle});

	var url = "{:U('home/User/searchTips')}";
	userAutoTips({id:'transpond_content_<?php echo $data['weibo_id']; ?>', url:url});
});

//检测输入字符数
function checkTranspondLength(obj,num){
	var $transpond_button = $('#transpond_button');
	var $transpond_count  = $('#transpond_count');
	var str = $(obj).val();
	var len = getLength(str, true);
	if(len==0){
		$transpond_button.attr('disabled',true).attr('class','btn_b_disable');
		$transpond_count.html('你还可以输入'+ (num-len) + '字');
	}else if( len > num ){
		$transpond_button.attr('disabled',true).attr('class','btn_b_disable');
		$transpond_count.css('color','red').html('已超出'+ (len-num) +'字');
	}else if( len <= num ){
		$transpond_button.removeAttr('disabled').attr('class','btn_b');
		$transpond_count.css('color','#008800').html('你还可以输入'+ (num-len) + '字');
	}
}
	
	function dotranspond(o){
		var options = {
			success:function(txt){
				if( txt ){
					<php>if($data['upcontent']){</php>
						$("#feed_list").prepend( txt ).slideDown('slow');
					<php>}</php>
					weibo.upCount('weibo');
				}else{
					alert('编辑失败');
				}
				location.reload();
			    ui.box.close();
			}
		};
		var $transpond_button = $('#transpond_button');
		$transpond_button.val('修改中...');
		$transpond_button.attr('disabled', 'true');
		$("#transpondForm").ajaxSubmit( options );
	}
	
	function createBc(title){
	var title = $("input[name='bcTitle']").val();
         
         if(title == ''){
		ui.error('请输入图格标题！');
		return false;
	}else if(title.length>20){
		ui.error('图格标题不能超过20个汉字');
		return false; 
	}
 
		$.post(U('weibo/Bc/setBc'),{title:title},function(gid){
			if(gid != 0){
                           
				// var url =   U('home/User/index'); 
                                //location.href=url;
				//ui.success('新建成功');
                                
                                var mySelect = document.getElementById("bc_id");  
                                //通过new Option(value,text)函数
                                var opp = new Option(title,gid); 
                                    opp.name = "option1"; 
                                    opp.selected = "ture";
                                    //将option添加到select标签里面 
                                    mySelect.add(opp); 
                                
                             
                            // $("#bc_id").html ('<option value="'+gid+'" selected>'+title+'</option>');    
                                
				//ui.box.close();
			}else{
				ui.error('此图格已存在');
			}
		});		
	 
}
	
</script>